/**
 * 
 */
package com.feeyin.radar.crm.model;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

import com.feeyin.radar.sys.model.Users;

/**
 * @author E547415
 *
 */
public class CostManage 
{
	private Integer id;
	private String costType;
	private String paymentAccount;
	private Integer status;
	private Integer personId;
	private String costId;
	private Date paymentDate;
	private Users person;
	private List<ContractCase> officalCCList;
	private List<ContractCase> operationCCList;

	public String getPersonName() {
		return person.getUserName();
	}	
	public Users getPerson() {
		return person;
	}
	public void setPerson(Users person) {
		this.person = person;
	}
	public List<ContractCase> getOfficalCCList() {
		return officalCCList;
	}
	public void setOfficalCCList(List<ContractCase> officalCCList) {
		this.officalCCList = officalCCList;
	}
	public List<ContractCase> getOperationCCList() {
		return operationCCList;
	}
	public void setOperationCCList(List<ContractCase> operationCCList) {
		this.operationCCList = operationCCList;
	}
	public Date getPaymentDate() {
		return paymentDate;
	}
	public void setPaymentDate(Date paymentDate) {
		this.paymentDate = paymentDate;
	}
	public String getCostId() {
		return costId;
	}
	public void setCostId(String costId) {
		this.costId = costId;
	}
	public Integer getId() {
		return id;
	}
	public void setId(Integer id) {
		this.id = id;
	}
	public String getCostType() {
		return costType;
	}
	public void setCostType(String costType) {
		this.costType = costType;
	}
	public String getPaymentAccount() {
		return paymentAccount;
	}
	public void setPaymentAccount(String paymentAccount) {
		this.paymentAccount = paymentAccount;
	}
	public Integer getStatus() {
		return status;
	}
	public void setStatus(Integer status) {
		this.status = status;
	}
	public Integer getPersonId() {
		return personId;
	}
	public void setPersonId(Integer personId) {
		this.personId = personId;
	}
	
	public Double getCostTotal()
	{
		Double costTotal = 0.0;
		if(("officialCost").equals(costType))
		{
			for(ContractCase cc : officalCCList)
				costTotal += cc.getOfficialCost();
		
		}
		if(("operationCost").equals(costType))
		{
			for(ContractCase cc : operationCCList)
				costTotal += cc.getOperationCost();
		}
		return costTotal;
	}
	
	public String getPaymentDateStr()
	{
		SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd");
		if(paymentDate==null)
			paymentDate = new Date();
		return sdf.format(paymentDate).toString();		
	}

}
